import java.util.Scanner;
public class Task {
    public static void main1(String[] args) {

        // 任务一：输出属相
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入您的出生年份：");
        int year = scanner.nextInt();
        int zodiacIndex = year % 12;
        switch (zodiacIndex) {
            case 0:
                System.out.println("您的属相是猴");
                break;
            case 1:
                System.out.println("您的属相是鸡");
                break;
            case 2:
                System.out.println("您的属相是狗");
                break;
            case 3:
                System.out.println("您的属相是猪");
                break;
            case 4:
                System.out.println("您的属相是鼠");
                break;
            case 5:
                System.out.println("您的属相是牛");
                break;
            case 6:
                System.out.println("您的属相是虎");
                break;
            case 7:
                System.out.println("您的属相是兔");
                break;
            case 8:
                System.out.println("您的属相是龙");
                break;
            case 9:
                System.out.println("您的属相是蛇");
                break;
            case 10:
                System.out.println("您的属相是马");
                break;
            case 11:
                System.out.println("您的属相是羊");
                break;
        }

        // 任务二：班级成绩统计
        int numStudents = 3;
        int numSubjects = 5;
        String[] studentNames = new String[numStudents];
        int[][] scores = new int[numStudents][numSubjects];
        int totalScore = 0;
        int classMaxScore = Integer.MIN_VALUE;
        int classMinScore = Integer.MAX_VALUE;

        for (int i = 0; i < numStudents; i++) {
            System.out.println("请输入第 " + (i + 1) + " 位学生的姓名：");
            studentNames[i] = scanner.next();
            int sum = 0;
            int maxScore = Integer.MIN_VALUE;
            int minScore = Integer.MAX_VALUE;

            for (int j = 0; j < numSubjects; j++) {
                System.out.println("请输入 " + studentNames[i] + " 的第 " + (j + 1) + " 门课成绩：");
                scores[i][j] = scanner.nextInt();
                sum += scores[i][j];
                if (scores[i][j] > maxScore) maxScore = scores[i][j];
                if (scores[i][j] < minScore) minScore = scores[i][j];
            }

            double average = sum / (double) numSubjects;
            System.out.println(studentNames[i] + " 的总成绩是：" + sum);
            System.out.println(studentNames[i] + " 的平均成绩是：" + average);
            System.out.println(studentNames[i] + " 的最高分是：" + maxScore);
            System.out.println(studentNames[i] + " 的最低分是：" + minScore);

            totalScore += sum;
            if (maxScore > classMaxScore) classMaxScore = maxScore;
            if (minScore < classMinScore) classMinScore = minScore;
        }

        double classAverage = totalScore / (double) (numStudents * numSubjects);
        System.out.println("班级的总分是：" + totalScore);
        System.out.println("班级的平均分是：" + classAverage);
        System.out.println("班级的最高分是：" + classMaxScore);
        System.out.println("班级的最低分是：" + classMinScore);
    }


    public static void main2(String[] args) {
        // 任务三：输出斐波那契数列的前20项
        int n = 20;
        int first = 0;
        int second = 1;
        int next;
        System.out.print("斐波那契数列的前" + n + "项:");
        for (int i = 0; i < n; i++) {
            if (i <= 1) {
                next = i;
            } else {
                next = first + second;
                first = second;
                second = next;
            }
            System.out.print(next + ",");
        }
        System.out.println();

        // 任务四：计算乌龟爬坡所需时间
        int distance = 100;
        int moveForward = 4;
        int moveBackward = 1;
        int currentDistance = 0;
        int hours = 0;
        while (true) {
            hours++;
            currentDistance += moveForward;
            if (currentDistance >= distance) {
                break;
            }
            currentDistance -= moveBackward;
        }
        System.out.println("乌龟爬坡需要" + hours + "小时才能首次到达终点。");
    }


    public static void main3(String[] args) {
        // 任务三：判断闰年
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入年份：");
        int year = scanner.nextInt();
        String isLeapYear = (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0) ? "是闰年" : "不是闰年";
        System.out.println(year + " " + isLeapYear);

        // 任务四：用户登录
        System.out.print("请输入用户名：");
        String username = scanner.next();
        System.out.print("请输入密码：");
        String password = scanner.next();
        String loginResult = (username.equals("admin") && password.equals("123")) ? "登录成功" : "用户名或密码不正确";
        System.out.println(loginResult);
    }

    public static void main4(String[] args) {


        Scanner sc = new Scanner(System.in);

        // 任务一：奇偶判断
        System.out.print("请输入一个整数：");
        int number = sc.nextInt();
        String oddOrEven = (number % 2 == 0) ? "偶数" : "奇数";
        System.out.println(number + " 是 " + oddOrEven);
    }



    public static void main(String[] args) {

        // 任务二：变量值交换
        System.out.print("请输入第一个整数：");
        int a = scanner.nextInt();
        System.out.print("请输入第二个整数：");
        int b = scanner.nextInt();

        // 交换变量a和b的值
        int temp = a;
        a = b;
        b = temp;

        System.out.println("交换后，第一个整数的值是：" + a);
        System.out.println("交换后，第二个整数的值是：" + b);
    }
}



